# 到入处理excel模块

import xlwings as xw

# 实例化一个应用 对象，可见性和add_book不启用
app = xw.App(visible=False, add_book=False)
app.display_alerts = False
app.screen_updating = False

file_path = r'C:\Users\cdou\Desktop\gzb.xlsx'

try:
    workbook = app.books.open(file_path)
    print(workbook)
    sheet = workbook.sheets[0]
    # column_a = sheet.range('A1:A1100')
    # av = column_a.value
    # print(av)
    cell = sheet.used_range
    print(cell)
    cv = cell.value
    print(cv)
    new_vl = []
    for i in cv:
        print(i)
        print(type(i))
        if i.find('F') == 2:
            new_vl.append(i)

    print("new_vl", new_vl)
    sheet.range('C1').options(transpose=True).value = new_vl
    workbook.save()
    workbook.close()
    app.quit()
except:
    workbook.close()
    app.quit()
